import { applyDecorators } from '@nestjs/common';
import { IsNumber, IsOptional, Min } from 'class-validator';
import { Type } from 'class-transformer';
import { ApiProperty } from '@nestjs/swagger';

export function SortValidator() {
  return applyDecorators(
    IsNumber(),
    Type(() => Number),
  );
}
export function StatusValidator() {
  return applyDecorators(
    IsOptional(),
    IsNumber(),
    Type(() => Number),
  );
}
export function IdValidator() {
  return applyDecorators(
    ApiProperty({ description: '用户id', example: 1 }),
    IsOptional(),
    IsNumber(),
    Min(1, { message: 'ID must be a positive number' }),
  );
}
